const fs = require('fs');

//使用promise链式调用

const p = new Promise((resolve , reject )=>{
    fs.readFile('/Users/tangwentao/VscodeProjects/ES6/13.promise基本语法.html',(err,data)=>{
        resolve(data);
    })
});


p.then(value=>{
    return new Promise((resolve,reject)=>{
        fs.readFile('/Users/tangwentao/VscodeProjects/ES6/13.promise基本语法.html',(err,data)=>{
            resolve([value,data]); //返回数组，后者的then只需要push到数组就行了。
        })
    });
}).then(value=>{
    return new Promise((resolve,reject)=>{
        fs.readFile('/Users/tangwentao/VscodeProjects/ES6/13.promise基本语法.html',(err,data)=>{
            value.push(data);
            resolve(value);
        })
    })
}).then(value=>{
    return new Promise((resolve,reject)=>{
        console.log(value.join('\r\n'));
    })
})

 

 